package com.ecommerce.demo.controller.test;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import com.ecommerce.demo.beans.test.Fruit;

@Controller
@RequestMapping("/fruit")
public class HelloController {

	@RequestMapping(value="{fruitName}", method = RequestMethod.GET)
	public String getFruit(@PathVariable String fruitName, ModelMap model) {
		System.out.println("hello");
		Fruit fruit = new Fruit(fruitName, 1000);
		model.addAttribute("model", fruit);
		return "contact";
 
	}
	
	@RequestMapping(value="/test", method = RequestMethod.GET)
	public String getJson(ModelMap model) {
		System.out.println("hello");
		Fruit fruit = new Fruit("orange", 1000);
		model.addAttribute("model", fruit);
		return "";
 
	}

	
}